<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: Structured forests for fast edge detection</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../d3/d81/tutorial_contrib_root.html">Tutorials for contrib modules</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Structured forests for fast edge detection </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h2>Introduction </h2>
<p>In this tutorial you will learn how to use structured forests for the purpose of edge detection in an image.</p>
<h2>Examples </h2>
<div class="image">
<img src="../../01.jpg" alt="01.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../02.jpg" alt="02.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../03.jpg" alt="03.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../04.jpg" alt="04.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../05.jpg" alt="05.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../06.jpg" alt="06.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../07.jpg" alt="07.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../08.jpg" alt="08.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../09.jpg" alt="09.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../10.jpg" alt="10.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../11.jpg" alt="11.jpg"/>
<div class="caption">
image</div></div>
 <div class="image">
<img src="../../12.jpg" alt="12.jpg"/>
<div class="caption">
image</div></div>
 <dl class="section note"><dt>Note</dt><dd>binarization techniques like Canny edge detector are applicable to edges produced by both algorithms (Sobel and StructuredEdgeDetection::detectEdges).</dd></dl>
<h2>Source Code </h2>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/**************************************************************************************</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">The structered edge demo requires you to provide a model.</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">This model can be found at the opencv_extra repository on Github on the following link:</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">https://github.com/opencv/opencv_extra/blob/master/testdata/cv/ximgproc/model.yml.gz</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">***************************************************************************************/</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="../../df/d6c/ximgproc_8hpp.html">opencv2/ximgproc.hpp</a>&gt;</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="../../d4/dd5/highgui_8hpp.html">opencv2/highgui.hpp</a>&quot;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="../../d1/d4e/utility_8hpp.html">opencv2/core/utility.hpp</a>&quot;</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="keyword">using namespace </span><a class="code" href="../../d2/d75/namespacecv.html">cv</a>;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="keyword">using namespace </span><a class="code" href="../../d9/d29/namespacecv_1_1ximgproc.html">cv::ximgproc</a>;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="keyword">const</span> <span class="keywordtype">char</span>* keys =</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;{</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;    <span class="stringliteral">&quot;{i || input image name}&quot;</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;    <span class="stringliteral">&quot;{m || model name}&quot;</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    <span class="stringliteral">&quot;{o || output image name}&quot;</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;};</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="keywordtype">int</span> main( <span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>** argv )</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;{</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <span class="keywordtype">bool</span> printHelp = ( argc == 1 );</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;    printHelp = printHelp || ( argc == 2 &amp;&amp; <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>(argv[1]) == <span class="stringliteral">&quot;--help&quot;</span> );</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;    printHelp = printHelp || ( argc == 2 &amp;&amp; <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>(argv[1]) == <span class="stringliteral">&quot;-h&quot;</span> );</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;    <span class="keywordflow">if</span> ( printHelp )</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    {</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        std::cout &lt;&lt; <span class="stringliteral">&quot;\nThis sample demonstrates structured forests for fast edge detection\n&quot;</span></div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;               <span class="stringliteral">&quot;Call:\n&quot;</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;               <span class="stringliteral">&quot;    structured_edge_detection -i=in_image_name -m=model_name [-o=out_image_name]\n\n&quot;</span>;</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;        <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    }</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    <a class="code" href="../../d0/d2e/classcv_1_1CommandLineParser.html">CommandLineParser</a> parser(argc, argv, keys);</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <span class="keywordflow">if</span> ( !parser.check() )</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    {</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        parser.printErrors();</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        <span class="keywordflow">return</span> -1;</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    }</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> modelFilename = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;m&quot;</span>);</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> inFilename = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;i&quot;</span>);</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> outFilename = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;o&quot;</span>);</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> image = <a class="code" href="../../d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56">imread</a>(inFilename, 1);</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <span class="keywordflow">if</span> ( image.empty() )</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        <a class="code" href="../../db/de0/group__core__utils.html#ga5b48c333c777666e076bd7052799f891">CV_Error</a>(<a class="code" href="../../d1/d0d/namespacecv_1_1Error.html#a759fa1af92f7aa7377c76ffb142abccaacf93e97abba2e7defa74fe5b99e122ac">Error::StsError</a>, <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>(<span class="stringliteral">&quot;Cannot read image file: &quot;</span>) + inFilename);</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <span class="keywordflow">if</span> ( modelFilename.size() == 0)</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;        <a class="code" href="../../db/de0/group__core__utils.html#ga5b48c333c777666e076bd7052799f891">CV_Error</a>(<a class="code" href="../../d1/d0d/namespacecv_1_1Error.html#a759fa1af92f7aa7377c76ffb142abccaacf93e97abba2e7defa74fe5b99e122ac">Error::StsError</a>, <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>(<span class="stringliteral">&quot;Empty model name&quot;</span>));</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    image.convertTo(image, <a class="code" href="../../d0/d3a/classcv_1_1DataType.html">DataType&lt;float&gt;::type</a>, 1/255.0);</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> edges(image.size(), image.type());</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;StructuredEdgeDetection&gt;</a> pDollar =</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;        <a class="code" href="../../de/d51/group__ximgproc__edge.html#ga39029b3c6691b0314b53c68c79d5b788">createStructuredEdgeDetection</a>(modelFilename);</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    pDollar-&gt;detectEdges(image, edges);</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    <span class="comment">// computes orientation from edge map</span></div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> orientation_map;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    pDollar-&gt;computeOrientation(edges, orientation_map);</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <span class="comment">// suppress edges</span></div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> edge_nms;</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    pDollar-&gt;edgesNms(edges, orientation_map, edge_nms, 2, 0, 1, <span class="keyword">true</span>);</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <span class="keywordflow">if</span> ( outFilename.size() == 0 )</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    {</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <a class="code" href="../../d7/dfc/group__highgui.html#ga5afdf8410934fd099df85c75b2e0888b">namedWindow</a>(<span class="stringliteral">&quot;edges&quot;</span>, 1);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;        <a class="code" href="../../d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563">imshow</a>(<span class="stringliteral">&quot;edges&quot;</span>, edges);</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;        <a class="code" href="../../d7/dfc/group__highgui.html#ga5afdf8410934fd099df85c75b2e0888b">namedWindow</a>(<span class="stringliteral">&quot;edges nms&quot;</span>, 1);</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;        <a class="code" href="../../d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563">imshow</a>(<span class="stringliteral">&quot;edges nms&quot;</span>, edge_nms);</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        <a class="code" href="../../d7/dfc/group__highgui.html#ga5628525ad33f52eab17feebcfba38bd7">waitKey</a>(0);</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    }</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="keywordflow">else</span></div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        <a class="code" href="../../d4/da8/group__imgcodecs.html#gabbc7ef1aa2edfaa87772f1202d67e0ce">imwrite</a>(outFilename, 255*edges);</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;}</div><div class="ttc" id="group__imgcodecs_html_gabbc7ef1aa2edfaa87772f1202d67e0ce"><div class="ttname"><a href="../../d4/da8/group__imgcodecs.html#gabbc7ef1aa2edfaa87772f1202d67e0ce">cv::imwrite</a></div><div class="ttdeci">bool imwrite(const String &amp;filename, InputArray img, const std::vector&lt; int &gt; &amp;params=std::vector&lt; int &gt;())</div><div class="ttdoc">Saves an image to a specified file. </div></div>
<div class="ttc" id="namespacecv_1_1Error_html_a759fa1af92f7aa7377c76ffb142abccaacf93e97abba2e7defa74fe5b99e122ac"><div class="ttname"><a href="../../d1/d0d/namespacecv_1_1Error.html#a759fa1af92f7aa7377c76ffb142abccaacf93e97abba2e7defa74fe5b99e122ac">cv::Error::StsError</a></div><div class="ttdoc">unknown /unspecified error </div><div class="ttdef"><b>Definition:</b> base.hpp:71</div></div>
<div class="ttc" id="group__imgcodecs_html_ga288b8b3da0892bd651fce07b3bbd3a56"><div class="ttname"><a href="../../d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56">cv::imread</a></div><div class="ttdeci">Mat imread(const String &amp;filename, int flags=IMREAD_COLOR)</div><div class="ttdoc">Loads an image from a file. </div></div>
<div class="ttc" id="group__core__basic_html_ga6395ca871a678020c4a31fadf7e8cc63"><div class="ttname"><a href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">cv::Ptr</a></div><div class="ttdeci">std::shared_ptr&lt; _Tp &gt; Ptr</div><div class="ttdef"><b>Definition:</b> cvstd_wrapper.hpp:23</div></div>
<div class="ttc" id="group__core__utils_html_ga5b48c333c777666e076bd7052799f891"><div class="ttname"><a href="../../db/de0/group__core__utils.html#ga5b48c333c777666e076bd7052799f891">CV_Error</a></div><div class="ttdeci">#define CV_Error(code, msg)</div><div class="ttdoc">Call the error handler. </div><div class="ttdef"><b>Definition:</b> base.hpp:320</div></div>
<div class="ttc" id="highgui_8hpp_html"><div class="ttname"><a href="../../d4/dd5/highgui_8hpp.html">highgui.hpp</a></div></div>
<div class="ttc" id="group__highgui_html_ga453d42fe4cb60e5723281a89973ee563"><div class="ttname"><a href="../../d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563">cv::imshow</a></div><div class="ttdeci">void imshow(const String &amp;winname, InputArray mat)</div><div class="ttdoc">Displays an image in the specified window. </div></div>
<div class="ttc" id="namespacecv_html"><div class="ttname"><a href="../../d2/d75/namespacecv.html">cv</a></div><div class="ttdoc">&quot;black box&quot; representation of the file storage associated with a file on disk. </div><div class="ttdef"><b>Definition:</b> affine.hpp:51</div></div>
<div class="ttc" id="classcv_1_1CommandLineParser_html"><div class="ttname"><a href="../../d0/d2e/classcv_1_1CommandLineParser.html">cv::CommandLineParser</a></div><div class="ttdoc">Designed for command line parsing. </div><div class="ttdef"><b>Definition:</b> utility.hpp:799</div></div>
<div class="ttc" id="group__ximgproc__edge_html_ga39029b3c6691b0314b53c68c79d5b788"><div class="ttname"><a href="../../de/d51/group__ximgproc__edge.html#ga39029b3c6691b0314b53c68c79d5b788">cv::ximgproc::createStructuredEdgeDetection</a></div><div class="ttdeci">Ptr&lt; StructuredEdgeDetection &gt; createStructuredEdgeDetection(const String &amp;model, Ptr&lt; const RFFeatureGetter &gt; howToGetFeatures=Ptr&lt; RFFeatureGetter &gt;())</div></div>
<div class="ttc" id="utility_8hpp_html"><div class="ttname"><a href="../../d1/d4e/utility_8hpp.html">utility.hpp</a></div></div>
<div class="ttc" id="group__highgui_html_ga5afdf8410934fd099df85c75b2e0888b"><div class="ttname"><a href="../../d7/dfc/group__highgui.html#ga5afdf8410934fd099df85c75b2e0888b">cv::namedWindow</a></div><div class="ttdeci">void namedWindow(const String &amp;winname, int flags=WINDOW_AUTOSIZE)</div><div class="ttdoc">Creates a window. </div></div>
<div class="ttc" id="namespacecv_1_1ximgproc_html"><div class="ttname"><a href="../../d9/d29/namespacecv_1_1ximgproc.html">cv::ximgproc</a></div><div class="ttdef"><b>Definition:</b> brightedges.hpp:47</div></div>
<div class="ttc" id="group__core__basic_html_ga1f6634802eeadfd7245bc75cf3e216c2"><div class="ttname"><a href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">cv::String</a></div><div class="ttdeci">std::string String</div><div class="ttdef"><b>Definition:</b> cvstd.hpp:150</div></div>
<div class="ttc" id="classcv_1_1DataType_html"><div class="ttname"><a href="../../d0/d3a/classcv_1_1DataType.html">cv::DataType</a></div><div class="ttdoc">Template &quot;trait&quot; class for OpenCV primitive data types. </div><div class="ttdef"><b>Definition:</b> traits.hpp:112</div></div>
<div class="ttc" id="classcv_1_1Mat_html"><div class="ttname"><a href="../../d3/d63/classcv_1_1Mat.html">cv::Mat</a></div><div class="ttdoc">n-dimensional dense array class </div><div class="ttdef"><b>Definition:</b> mat.hpp:801</div></div>
<div class="ttc" id="group__highgui_html_ga5628525ad33f52eab17feebcfba38bd7"><div class="ttname"><a href="../../d7/dfc/group__highgui.html#ga5628525ad33f52eab17feebcfba38bd7">cv::waitKey</a></div><div class="ttdeci">int waitKey(int delay=0)</div><div class="ttdoc">Waits for a pressed key. </div></div>
<div class="ttc" id="ximgproc_8hpp_html"><div class="ttname"><a href="../../df/d6c/ximgproc_8hpp.html">ximgproc.hpp</a></div></div>
</div><!-- fragment --><h2>Explanation </h2>
<ol type="1">
<li><b>Load source color image</b> <div class="fragment"><div class="line"><a class="code" href="../../d3/d63/classcv_1_1Mat.html">cv::Mat</a> image = <a class="code" href="../../d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56">cv::imread</a>(inFilename, 1);</div><div class="line"><span class="keywordflow">if</span> ( image.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abbec3525a852e77998aba034813fded4">empty</a>() )</div><div class="line">{</div><div class="line">    printf(<span class="stringliteral">&quot;Cannot read image file: %s\n&quot;</span>, inFilename.c_str());</div><div class="line">    <span class="keywordflow">return</span> -1;</div><div class="line">}</div></div><!-- fragment --></li>
<li><b>Convert source image to [0;1] range</b> <div class="fragment"><div class="line">image.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#adf88c60c5b4980e05bb556080916978b">convertTo</a>(image, <a class="code" href="../../d0/d3a/classcv_1_1DataType.html">cv::DataType&lt;float&gt;::type</a>, 1/255.0);</div></div><!-- fragment --></li>
<li><b>Run main algorithm</b> <div class="fragment"><div class="line"><a class="code" href="../../d3/d63/classcv_1_1Mat.html">cv::Mat</a> edges(image.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a146f8e8dda07d1365a575ab83d9828d1">size</a>(), image.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#af2d2652e552d7de635988f18a84b53e5">type</a>());</div><div class="line"></div><div class="line"><a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">cv::Ptr&lt;StructuredEdgeDetection&gt;</a> pDollar =</div><div class="line">    <a class="code" href="../../de/d51/group__ximgproc__edge.html#ga39029b3c6691b0314b53c68c79d5b788">cv::createStructuredEdgeDetection</a>(modelFilename);</div><div class="line">pDollar-&gt;detectEdges(image, edges);</div></div><!-- fragment --></li>
<li><b>Show results</b> <div class="fragment"><div class="line"><span class="keywordflow">if</span> ( outFilename == <span class="stringliteral">&quot;&quot;</span> )</div><div class="line">{</div><div class="line">    <a class="code" href="../../d7/dfc/group__highgui.html#ga5afdf8410934fd099df85c75b2e0888b">cv::namedWindow</a>(<span class="stringliteral">&quot;edges&quot;</span>, 1);</div><div class="line">    <a class="code" href="../../d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563">cv::imshow</a>(<span class="stringliteral">&quot;edges&quot;</span>, edges);</div><div class="line"></div><div class="line">    <a class="code" href="../../d7/dfc/group__highgui.html#ga5628525ad33f52eab17feebcfba38bd7">cv::waitKey</a>(0);</div><div class="line">}</div><div class="line"><span class="keywordflow">else</span></div><div class="line">    <a class="code" href="../../d4/da8/group__imgcodecs.html#gabbc7ef1aa2edfaa87772f1202d67e0ce">cv::imwrite</a>(outFilename, 255*edges);</div></div><!-- fragment --></li>
</ol>
<h2>Literature </h2>
<p>For more information, refer to the following papers : <a class="el" href="../../d0/de3/citelist.html#CITEREF_Dollar2013">[57]</a> <a class="el" href="../../d0/de3/citelist.html#CITEREF_Lim2013">[150]</a> </p>
</div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:40 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
